/*
package com.usian.listener;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.usian.model.article.pojos.ApArticleConfig;
import com.usian.service.ApArticleConfigService;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.Optional;

@Component
public class MsgListener {

    @Autowired
    private ApArticleConfigService apArticleConfigService;


    @KafkaListener(topics = "shangxiajia")
    public void receiverMessage(ConsumerRecord<?,?> record){
        Optional<? extends ConsumerRecord<?, ?>> optional = Optional.ofNullable(record);
        if(optional.isPresent()){
            Object value = record.value();
            Map<String,Object> map = JSON.parseObject(value.toString(), Map.class);

            //更新 ap——article-config
            apArticleConfigService.update(Wrappers.<ApArticleConfig>lambdaUpdate()
                    .set(ApArticleConfig::getIsDown,map.get("enable"))
                    .eq(ApArticleConfig::getArticleId,map.get("articleId")));
        }
    }
}
*/
